import baseUrl from "./path.js"
export default {
	fomartTime:function(timestamp){
		var date = new Date(timestamp * 1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
		var Y = date.getFullYear() + '-';
		var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
		var D = date.getDate() < 10 ? '0'+date.getDate() : date.getDate()
		var h = date.getHours() + ':';
		var m = date.getMinutes() + ':';
		var s = date.getSeconds();
		return Y+M+D;
	},
	getFileType:function(str) {
        var array = str.split('.');
        var length = array.length;
        if(length > 0) {
            return array[length - 1];
         } else {
            return ''
        }
    },
	now:function(){
	        var myDate = new Date();
		    var year=myDate.getFullYear();    //获取完整的年份(4位,1970-????)
		    var month=myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
		    var date=myDate.getDate();        //获取当前日(1-31)
			var nowTime = year+"."+month+"."+date
		    var nowDay = "星期" + "日一二三四五六".charAt(new Date().getDay());
			return {
				nowTime:nowTime,
				nowDay:nowDay
			}
	},
	getPageNum:function(total,num) {
		if(num < total) {
			return 1
		}else {
			const reszult = total / num
			if (total%num == 0) {
				return reszult
			} else {
				return  parseInt(reszult) + 1
			}
		}
	},
	verifyStatus:function(num) {
		if (num == 0) {
			return "待审核"
		}
		if (num == 1) {
			return "审核通过"
		}
		if (num == 2) {
			return "审核不通过"
		}
	},
	getPing:function(num) {
		if (num == 1) {
			return "优秀"
		}
		if (num == 2) {
			return "合格"
		}
		if (num == 3) {
			return "待合格"
		}
		if (!num) {
			return ""
		}
	},
	getWork:function(str) {
		if (str == 'type_1') {
			return "必选作业"
		}
		if (str == 'type_2') {
			return "选做作业"
		}
		if (str == 'type_3') {
			return "挑战作业"
		}
		if (str == 'type_4') {
			return "实践作业"
		}
	},
	sh:function(num) {
		if (num == 0) {
			return "审核中"
		}
		if (num == 1) {
			return "审核通过"
		}
		if (num == 2) {
			return "审核不通过"
		}
	},
    getCover:function(array) {
		// console.log(array);
	    let cover = '';
		for (let i = 0; i < array.length; i++) {
		  if (array[i].ext == 'mp4' || array[i].ext == 'jpg' || array[i].ext == 'png')  {
		    cover = array[i].vframe_url;
		    break
		  } else {
			if(array[i].vframe_url) {
				cover = array[i].vframe_url;
				 break;
			} else {
				cover = baseUrl.static +'word3.png';
			}
		  }
		}
	    return cover;
		
	}
}

